package gat.api.rest.background.tg;

import com.bitsun.core.common.persistence.Pager;
import com.bitsun.core.common.web.ResultDTO;
import gat.api.background.tg.ChatBindRecordApi;
import gat.api.config.annotation.CheckPermissions;
import gat.application.tg.ChatBindRecordService;
import gat.dto.req.tg.ChatBindRecordReqParams;
import gat.dto.req.tg.TgBotReqParams;
import gat.dto.res.tg.ChatBindRecordResDto;
import gat.dto.res.tg.TgBotResDto;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 绑定账号
 * @Author: yanshukeji-java
 * @Email: yanshukeji-java
 */
@Slf4j
@SuppressWarnings("unchecked")
@RestController
@RequestMapping("/chatBindRecord")
public class ChatBindRecordApiController implements ChatBindRecordApi {


    @Autowired
    private ChatBindRecordService chatBindRecordService;


    /**
     * 解绑
     * @param ids
     * @return
     */
    @CheckPermissions(value = "chatBindRecord:deleted")
    @DeleteMapping(value = "/{ids}", produces = {"application/json"})
    public ResultDTO<Void> deleteChatBindRecord(
            @ApiParam(value = "要删除的对象主键，多个对象主键可以用英文逗号隔开", required = true) @PathVariable("ids") String ids) {
        boolean bl = chatBindRecordService.deleteByIds(ids);
        return ResultDTO.ok();
    }

    // 绑定记录 分页查询

    /**
     * 绑定记录 分页查询
     * @param params
     * @return
     */
    @CheckPermissions(value = "chatBindRecord:queryPage")
    @GetMapping(produces = {"application/json"})
    public ResultDTO<Pager<ChatBindRecordResDto>> queryPage(ChatBindRecordReqParams params) {
        Pager<ChatBindRecordResDto> resDtoPager = chatBindRecordService.queryPage(params);
        return ResultDTO.ok(resDtoPager);
    }

}
